package com.young.android.business;

import java.util.ArrayList;

import com.young.android.atomoperation.OperItem;
import com.young.android.atomoperation.OperResource;
import com.young.android.entity.Resource;

public class ResourceBusi {

    public static ArrayList<Resource> getAllRes() {
        ArrayList<Resource> rList = OperResource.getAllResources();
        return rList;
    }

    public static int deleteRes(String url) {
        Resource r = new Resource();
        r.url = url;
        OperItem.deleteItem(r.url);     //级联操作
        return OperResource.deleteResource(r);
    }

    /**
     * 插入一条记录
     * @param r
     * @return
     */
    public static int insertRes(Resource r) {
        return OperResource.insertResource(r);
    }
    
    /**
     * 获取未读条数
     * @param url
     * @return
     */
    public static int getUnreadCount(String url){
        return ItemBusi.getUnreadCountByURL(url);
    }
    
    /**
     * 获取所有的RSS连接源
     * @return
     */
    public static ArrayList<Resource> getAllResources(){
        return OperResource.getAllResources();
    }
    
    /**
     * 修改RSS源
     * @param r
     * @param url
     * @return
     */
    public static int editResource(Resource r,String url){
        return OperResource.updateResource(r, url);
    }
    
}
